<%--
  Created by IntelliJ IDEA.
  User: windows
  Date: 2021/10/29
  Time: 10:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>列表</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css">
    <script src="${pageContext.request.contextPath}/layui/layui.js"></script>
    <script src="${pageContext.request.contextPath}/js/jquery-3.6.0.js"></script>
</head>
<body>

<div style="border-radius: 5px;margin-top: 100px;margin-left: 700px;margin-right: 700px">
    <table id="demo" lay-filter="table-excel-filter"></table>
</div>

<script type="text/html" id="col-excel-toolbar">
    <a class="layui-btn layui-btn-xs" lay-event="upload">下载</a>
</script>
<script>

    layui.use(['laydate', 'table', 'form'], function () {
        var table = layui.table;

        table.render({
            elem: '#demo'
            , height: 312
            , url: '/data.jsp' //数据接口
            , page: false //关闭分页
            , cols: [[ //表头
                {field: 'name', title: 'name', width: 300}
                , {title: '操作', align: 'center', toolbar: '#col-excel-toolbar'}
            ]]
        });

        table.on('tool(table-excel-filter)', function (obj) {
            let data = obj.data;
            let layEvent = obj.event;
            if (layEvent === 'upload') {
                console.log(data.name)
                console.log("list name: " + data.name);
                sessionStorage.setItem("name", data.name)
                // let url = '/transfer.jsp'
                let url = '/download'
                window.location.href = url + "?name=" + data.name
                // layer.open({
                //     type: 2,
                //     title: "查看图片",
                //     area: ['60%', '60%'],
                //     shadeClose: true,
                //     content: url
                // });
            }
        });
    });

</script>
</body>
</html>


